-
Notifications
You must be signed in to change notification settings - Fork 8
Use proper classes #235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use proper classes #235
Conversation
5f7578e
to
36653c5
Compare
Had a look, it works on my system and I can now do things like However, member functions that return a reference to the cxx object now cause unintuitive behavior, e.g. k1 = Kambites(Word=str)
assert isinstance(k1, Kambites) # Passes
k2 = k1.init()
assert isinstance(k2, Kambites) # Fails since the E.g. something like _internal_to_wrapper_dict = {
KambitesWords: Kambites,
KambitesStrings: Kambites,
PresentationWords: Presentation,
PresentationStrings: Presentation, # Every time we add a wrapper register it here
}
def internal_to_wrapper(x):
if type(x) in _internal_to_wrapper_dict:
return _internal_to_wrapper_dict[type(x)](x)
return x and then we wrap the return of Another way would be to somehow make |
Thanks for the comments @reiniscirpons, that's an oversight on my behalf about the return value of Some comments: I don't think the new approach really uses
All of that is to say that I think the best thing is just to explicitly declare the methods that should return |
Ah ok, I overlooked the
Sounds good, this is probably the simplest fix. One extra issue might be if we have any member function which returns a different wrapped type (e.g. a Congruence returning a ToddCoxeter), but for Congruence this is already handled a with the |
I think I've accounted for the issues that you pointed out @reiniscirpons if you have any other comments, please let me know! O/w I'll continue with the other classes |
Looks good to me. I will implement a similar approach for |
7d11e75
to
c95a207
Compare
c95a207
to
756a59b
Compare
88ea007
to
6019bc3
Compare
In 6019bc3, we update our custom extension to look for inserted signatures at the start of a docstring. If the name of the function in the inserted signature does not match the name of the function being documented (e.g. This means that we can remove the |
I think this is now complete from my perspective @Joseph-Edwards |
Sweet! Thanks @james-d-mitchell. I'll try and review the changes/use the package over the next couple of days and try and get it merged. |
|
Oooh right I merge that but didn't check, I'll fix that now |
Co-authored-by: James Mitchell <james-d-mitchell@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR looks awesome; thanks @james-d-mitchell! I've made a few minor suggestions below. Some will be quick fixes, but others may require a bit of discussion about the best course of action. The main point relates to unused imports, but this is quite inconsequential. Overall looks great :)
Co-authored-by: Joe Edwards <80713360+Joseph-Edwards@users.noreply.github.com>
Co-authored-by: Joe Edwards <80713360+Joseph-Edwards@users.noreply.github.com>
Co-authored-by: Joe Edwards <80713360+Joseph-Edwards@users.noreply.github.com>
Co-authored-by: Joe Edwards <80713360+Joseph-Edwards@users.noreply.github.com>
Co-authored-by: Joe Edwards <80713360+Joseph-Edwards@users.noreply.github.com>
I think it would be very helpful to have a way of formatting the rst code, but some of the changes introduced in 2fc2c51 don't interact with Sphinx's autodoc stuff very well. For example, in paths.rst, the entries in the It looks like most of the stuff has been formatted well though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for making the changes @james-d-mitchell. I think I've spotted a few more places where we can remove unused-imports
. Otherwise, once the tests pass, I'm happy to merge this.
Co-authored-by: Joe Edwards <80713360+Joseph-Edwards@users.noreply.github.com>
Co-authored-by: Joe Edwards <80713360+Joseph-Edwards@users.noreply.github.com>
Co-authored-by: Joe Edwards <80713360+Joseph-Edwards@users.noreply.github.com>
Co-authored-by: Joe Edwards <80713360+Joseph-Edwards@users.noreply.github.com>
Hmmm I’m not seeing any warnings when I run make doc, are you? If so, can you please post them? Thanks! |
I don't get any warnings either. It just seemed odd that the As far as I can tell, this hasn't changed the appearance of the doc itself. |
Ah right, I think it was pretty inconsistent before too, so I'm not sure it's now worse than before. I should file an issue with Are you happy for this to be merged? |
Yeah in that case I'm happy to merge. Thanks again @james-d-mitchell |
This PR intends to replace the "functions pretending to be classes" in
libsemigroups_pybind11
with proper classes derived fromCxxWrapper
.The functions that need to be converted are:
Congruence
KnuthBendix
Kambites
ToddCoxeter
Presentation
InversePresentation
FroidurePin
Konieczny
and I think that's all. @reiniscirpons, I've implemented something that ticks all the boxes for me for the
Congruence
class, if you have any feedback, then I'd be happy to hear it!